package it.afs.wicket;

import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.StringResourceModel;

public abstract class AjaxLinkButton<T> extends AjaxLink<T>
{
	private static final long serialVersionUID = -7093393497073796448L;
	
	private StringResourceModel valueModel, titleModel;
	
	public AjaxLinkButton(String id, IModel<T> model, StringResourceModel valueModel)
	{
		this(id, model, valueModel, null);
	}
	
	public AjaxLinkButton(String id, IModel<T> model, StringResourceModel valueModel, StringResourceModel titleModel)
	{
		super(id, model);
		this.valueModel = valueModel;
		this.titleModel = titleModel;
	}
	
	@Override
	protected void onComponentTag(ComponentTag tag)
	{
		if(valueModel!=null)
			tag.put("value", valueModel.getString());
		
		if(titleModel!=null)
			tag.put("title", titleModel.getString());
		
		super.onComponentTag(tag);
	}
}
